package wzyouxibao;
 class AssassinHero extends Hero{
    private int critRate;
    private int critDamage;

    public AssassinHero(String name,int hp,int attack,int defense,int magicResist,
                        int moveeSeepd,String[] skills, int critRate,int critDamage){
        super(name,"刺客",hp,attack,defense,magicResist,moveeSeepd,skills);
        this.critRate=critRate;
        this.critDamage=critDamage;
    }

    public int getCritRate(){
        return critRate;
    }

    public void setCritRate(int critRate){
        this.critRate=critRate;
    }

    public int getCritDamage(){
        return critDamage;
    }

    public void setCritDamage(int critDamage){
        this.critDamage=critDamage;
    }

    @Override
     public void normalAttack(Hero target){
        boolean isCrit=Math.random()*100<critRate;
        int damage;

        if (isCrit){
            damage=(int)(getAttack()*(1+critDamage/100.0))- target.getDefense()/2;
            System.out.println(getName()+"触发暴击");
        }else {
            damage=getAttack()- target.getDefense()/2;
        }

        if(damage<0)damage=0;
        target.setHp(target.getHp()-damage);
        System.out.println(getName()+"对"+target.getName()+"造成了"+damage+"点伤害");
    }

    public void stealth(){
        System.out.println(getName()+"进入了隐身状态！");
    }

    @Override
     public void displayStatus(){
        super.displayStatus();
        System.out.println("暴击率"+critRate+"%");
        System.out.println("暴击伤害"+critDamage+"%");
    }

    @Override
     public void levelUp(){
        super.levelUp();
        critRate+=2;
        critDamage+=5;
        System.out.println("刺客特性激活！暴击率提升2%，暴击伤害提升5%");
    }

}

public class Jcyingxiong {
     public static void main(String[] args){
         String[] skills={"影袭","暗杀","瞬杀"};
         AssassinHero lan=new AssassinHero("兰陵王",2800,180,120,80,380,skills,20,150);

         String[] tankSkills={"盾击","嘲讽","坚守"};
         Hero yase=new Hero("亚瑟","坦克",3500,150,200,120,350,tankSkills);

         lan.displayStatus();
         yase.displayStatus();

         System.out.println("\n===战斗开始===");
         lan.normalAttack(yase);
         lan.useSkill(0,yase);
         lan.stealth();

         System.out.println("\n===获得经验===");
         lan.gainExp(120);
         lan.displayStatus();
     }
}
